package com.smart.nacos.provider.controller;

import com.smart.nacos.provider.reqeust.UserReqeust;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/provider")
public class ProviderController {
    @Value("${server.port}")
    private int port;

    @GetMapping("/")
    public String hello() {
        return port + "";
    }

    /**
     * 普通参数基本类型
     *
     * @return
     */
    @GetMapping("/msg")
    public String hello(String msg) {
        return msg;
    }

    @GetMapping("/user/list")
    public String list(UserReqeust userReqeust) {
        return userReqeust.getUsername();
    }

    @GetMapping("/user/obj")
    public String obj(UserReqeust userReqeust) {
        return userReqeust.getUsername();
    }

    @PostMapping("/user/json")
    public String json(@RequestBody UserReqeust userReqeust) {
        return userReqeust.getUsername();
    }
}
